<!--main-->
<div class="search_top">
	<ul class="pagenavi">
		<li><a href="#">首页</a></li>
		<li class="li2">搜索企业</li>
	</ul>
</div>
<div class="search_main">
	<div class="search_main_title">搜索您要点评的企业</div>
	<div class="search_main_1">
		<div class="main_table">
		<form action="search.php" method="post">
		<table cellpadding="0" cellspacing="0" border="0">
			<tr>
				<td>
					<input id="searchKey" name="search_name" type="text" value="输入企业名称或地址" autocomplete="off">&nbsp;<input type="radio" name="searchType" value="name" checked="checked">按名称<input type="radio" name="searchType" value="address">按地址
					<div class="show_name" style="display:none;"><ul></ul></div>
				</td>
			</tr>
			<tr align="center">
				<td><br/><input type="image"  src="images/index_submit.gif"></td>
			</tr>
		</table>
		</form>
		</div>
	</div>
</div>
<!--main end -->
<script type="text/javascript" src="/script/jquery.js"></script>
<script type="text/javascript" src="/script/common.js"></script>
<script>
	$(document).ready(function(){
		
		$("#searchKey").focus(function(){
			if($(this).val() == "输入企业名称或地址" ){
				$(this).val('');
			}
		}).blur(function(){
			if($(this).val() == ""){
				$(this).val('输入企业名称或地址');
			}
		}).keydown(function(){
			var content = $(this).val();
			var searchType = $("input[name='searchType'][type='radio']:checked").val();
			if(content.length >= 2){
				$.ajax({
					type:"POST",
					url:"searchajax.php",
					data:"searchKey="+encodeURIComponent(content)+"&searchType="+searchType,
					dataType:"json",
					success:function(msg){
						if(msg == "nofind"){
							return false;
						}else{
							var reArr = eval(msg);
							showAjax(reArr);
						}
					}            
				 });
			}
		});
		
		$(document).click(function(){
			$(".show_name").hide();
		});
		
		function showAjax(reArr)
		{
			var htmlStr = "";
			for(var i=0; i<reArr.length; i++){
				var temp = reArr[i].split("#|#");
				htmlStr += '<li class="corlink"><a href="'+temp[1]+'" target="_blank">'+temp[0]+'</a></li>'; 
			}
			$(".show_name").show();
			$(".show_name ul").html(htmlStr);
			$(".show_name li").mouseover(function(){
				$(this).removeClass().addClass("corhover");
			}).mouseout(function(){
				$(this).removeClass().addClass("corlink");
			});
		}
	});
</script>
